package edu.ahut.corejava3;

import java.util.HashMap;
import java.util.Map;

public class MapDemo {
    public static void main(String[] args) {
        Map<String,String> users=new HashMap<String, String>();//create table
        users.put("tom","cat");//insert record
        users.put("guest","1234");
        users.put("root","root");
        System.err.println(users);
        users.remove("tom");//delete row
        System.err.println(users);
        users.put("guest","123456");//update guest password from 1234 to 123456;
        System.err.println(users);
        String guestPassword=users.get("guest");

        System.out.println(guestPassword);//输出
        System.err.println(users);
        System.out.println(users.containsKey("tom"));//false


        System.err.println(users);

        System.out.println("keyset="+users.keySet());
        System.out.println("values="+users.values());

        for(String username:users.keySet()){
            System.out.println(username+"\t"+users.get(username));
        }

    }
}
